package com.yashi.springmvcjbpm.mail;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.jbpm.api.ExecutionService;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.TaskService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.yashi.springmvcjbpm.service.impl.JBPMServiceImpl;
import com.yashi.springmvcjbpm.util.JBPMUtil;

public class Test {
//	public static void main(String[] args) {
//		JBPMServiceImpl jbpmServiceImpl = new JBPMServiceImpl();
//		JBPMUtil jbpmUtil = new JBPMUtil();
//		ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
//				"database/spring-hibernate.xml");
//		applicationContext.start();
//		ProcessEngine processEngine = (ProcessEngine) applicationContext.getBean("processEngine");
//		ExecutionService executionService = processEngine.getExecutionService();
//		TaskService taskService = processEngine.getTaskService();
//
//		// 发布流程
//		
////		  String deploymentId = processEngine.getRepositoryService().createDeployment()
////		  .addResourceFromClasspath("mail/mail.jpdl.xml").deploy();
////		  System.out.println("流程发布 ID:"+deploymentId);
////		 
////		  String pdId = jbpmServiceImpl.getAllPd().get(0).getId(); // 获得第一个Id
////			System.out.println("pdid="+pdId);
//		  
//		String addressee = "187289092@qq.com";
//		String newspaper = "恭喜你 ";
//		Date date = new Date();
//		String details = "继续加油吧 ";
//
//		Map<String, Object> variables = new HashMap<String, Object>();
//		variables.put("addressee", addressee);
//		variables.put("newspaper", newspaper);
//		variables.put("date", date);
//		variables.put("details", details);
//		System.out.println("map="+variables);
//		// 启动一个流程实例
////		ProcessInstance processInstance = jbpmUtil.startPIById(id, map); // 开始流程实例
//		ProcessInstance processInstance = executionService.startProcessInstanceByKey("TemplateMail");
//		System.out.println("流程实例 ID:" + processInstance.getId());
//	}
}
